<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The EventUtil class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="eventsslcontext.construct.html">EventSslContext::__construct</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="eventutil.construct.html">EventUtil::__construct</a></div>
 <div class="up"><a href="book.event.html">Event</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.eventutil" class="reference">
 <h1 class="title">The EventUtil class</h1>
 
 <div class="partintro"><p class="verinfo">(PECL event &gt;= 1.5.0)</p>

  <div class="section" id="eventutil.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    <strong class="classname">EventUtil</strong>
    is a singleton with supplimentary methods and constants.
   </p>
  </div>

  <div class="section" id="eventutil.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">final</span>
      <strong class="classname">EventUtil</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.af-inet"><var class="varname">AF_INET</var></a></var>
     <span class="initializer"> = 2</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.af-inet6"><var class="varname">AF_INET6</var></a></var>
     <span class="initializer"> = 10</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.af-unspec"><var class="varname">AF_UNSPEC</var></a></var>
     <span class="initializer"> = 0</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.libevent-version-number"><var class="varname">LIBEVENT_VERSION_NUMBER</var></a></var>
     <span class="initializer"> = 33559808</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-debug"><var class="varname">SO_DEBUG</var></a></var>
     <span class="initializer"> = 1</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-reuseaddr"><var class="varname">SO_REUSEADDR</var></a></var>
     <span class="initializer"> = 2</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-keepalive"><var class="varname">SO_KEEPALIVE</var></a></var>
     <span class="initializer"> = 9</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-dontroute"><var class="varname">SO_DONTROUTE</var></a></var>
     <span class="initializer"> = 5</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-linger"><var class="varname">SO_LINGER</var></a></var>
     <span class="initializer"> = 13</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-broadcast"><var class="varname">SO_BROADCAST</var></a></var>
     <span class="initializer"> = 6</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-oobinline"><var class="varname">SO_OOBINLINE</var></a></var>
     <span class="initializer"> = 10</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-sndbuf"><var class="varname">SO_SNDBUF</var></a></var>
     <span class="initializer"> = 7</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-rcvbuf"><var class="varname">SO_RCVBUF</var></a></var>
     <span class="initializer"> = 8</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-sndlowat"><var class="varname">SO_SNDLOWAT</var></a></var>
     <span class="initializer"> = 19</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-rcvlowat"><var class="varname">SO_RCVLOWAT</var></a></var>
     <span class="initializer"> = 18</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-sndtimeo"><var class="varname">SO_SNDTIMEO</var></a></var>
     <span class="initializer"> = 21</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-rcvtimeo"><var class="varname">SO_RCVTIMEO</var></a></var>
     <span class="initializer"> = 20</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-type"><var class="varname">SO_TYPE</var></a></var>
     <span class="initializer"> = 3</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.so-error"><var class="varname">SO_ERROR</var></a></var>
     <span class="initializer"> = 4</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.sol-socket"><var class="varname">SOL_SOCKET</var></a></var>
     <span class="initializer"> = 1</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.sol-tcp"><var class="varname">SOL_TCP</var></a></var>
     <span class="initializer"> = 6</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.sol-udp"><var class="varname">SOL_UDP</var></a></var>
     <span class="initializer"> = 17</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.ipproto-ip"><var class="varname">IPPROTO_IP</var></a></var>
     <span class="initializer"> = 0</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.eventutil.html#eventutil.constants.ipproto-ipv6"><var class="varname">IPPROTO_IPV6</var></a></var>
     <span class="initializer"> = 41</span>
    ;</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">abstract</span>
   <span class="modifier">public</span>
   <span class="methodname"><a href="eventutil.construct.html" class="methodname">__construct</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">int</span>
   <span class="methodname"><a href="eventutil.getlastsocketerrno.html" class="methodname">getLastSocketErrno</a></span>
    ([ <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$socket</code>
    <span class="initializer"> = <strong><code>NULL</code></strong></span>
   </span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">string</span>
   <span class="methodname"><a href="eventutil.getlastsocketerror.html" class="methodname">getLastSocketError</a></span>
    ([ <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$socket</code>
   </span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">int</span>
   <span class="methodname"><a href="eventutil.getsocketfd.html" class="methodname">getSocketFd</a></span>
    ( <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$socket</code>
   </span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">bool</span>
   <span class="methodname"><a href="eventutil.getsocketname.html" class="methodname">getSocketName</a></span>
    ( <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$socket</code>
   </span>
   , <span class="methodparam">
    <span class="type">string</span>
     <code class="parameter reference">&$address</code>
   </span>
   [, <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter reference">&$port</code>
   </span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">bool</span>
   <span class="methodname"><a href="eventutil.setsocketoption.html" class="methodname">setSocketOption</a></span>
    ( <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$socket</code>
   </span>
   , <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$level</code>
   </span>
   , <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$optname</code>
   </span>
   , <span class="methodparam">
    <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$optval</code>
   </span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">void</span>
   <span class="methodname"><a href="eventutil.sslrandpoll.html" class="methodname">sslRandPoll</a></span>
    ( <span class="methodparam">void</span>
   )</div>

   }</div>

  </div>

  <div class="section" id="eventutil.constants">
   <h2 class="title">预定义常量</h2>
   <dl>

    
     <dt id="eventutil.constants.af-inet">
      <strong><code>EventUtil::AF_INET</code></strong>
     </dt>

     <dd>

      <p class="para">
       IPv4 address family
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.af-inet6">
      <strong><code>EventUtil::AF_INET6</code></strong>
     </dt>

     <dd>

      <p class="para">
       IPv6 address family
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.af-unspec">
      <strong><code>EventUtil::AF_UNSPEC</code></strong>
     </dt>

     <dd>

      <p class="para">
       Unspecified IP address family
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-debug">
      <strong><code>EventUtil::SO_DEBUG</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. Enable socket debugging. Only allowed for processes with
       the
       <em>CAP_NET_ADMIN</em>
       capability or an effective user ID of
       <strong><code>0</code></strong>
       . (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-reuseaddr">
      <strong><code>EventUtil::SO_REUSEADDR</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. Indicates that the rules used in validating addresses
       supplied in a
       <em>bind(2)</em>
       call should allow reuse of local addresses. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-keepalive">
      <strong><code>EventUtil::SO_KEEPALIVE</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. Enable sending of keep-alive messages on
       connection-oriented sockets. Expects an integer boolean flag. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-dontroute">
      <strong><code>EventUtil::SO_DONTROUTE</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-linger">
      <strong><code>EventUtil::SO_LINGER</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. When enabled, a
       <em>close(2)</em>
       or
       <em>shutdown(2)</em>
       will not return until all queued messages for the socket have been
       successfully sent or the linger timeout has been reached. Otherwise,
       the call returns immediately and the closing is done in the background.
       See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-broadcast">
      <strong><code>EventUtil::SO_BROADCAST</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. Reports whether transmission of broadcast messages is
       supported. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-oobinline">
      <strong><code>EventUtil::SO_OOBINLINE</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-sndbuf">
      <strong><code>EventUtil::SO_SNDBUF</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-rcvbuf">
      <strong><code>EventUtil::SO_RCVBUF</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-sndlowat">
      <strong><code>EventUtil::SO_SNDLOWAT</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-rcvlowat">
      <strong><code>EventUtil::SO_RCVLOWAT</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-sndtimeo">
      <strong><code>EventUtil::SO_SNDTIMEO</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-rcvtimeo">
      <strong><code>EventUtil::SO_RCVTIMEO</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-type">
      <strong><code>EventUtil::SO_TYPE</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.so-error">
      <strong><code>EventUtil::SO_ERROR</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.sol-socket">
      <strong><code>EventUtil::SOL_SOCKET</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option level. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.sol-tcp">
      <strong><code>EventUtil::SOL_TCP</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option level. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.sol-udp">
      <strong><code>EventUtil::SOL_UDP</code></strong>
     </dt>

     <dd>

      <p class="para">
       Socket option level. See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.ipproto-ip">
      <strong><code>EventUtil::IPPROTO_IP</code></strong>
     </dt>

     <dd>

      <p class="para">
       See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.ipproto-ipv6">
      <strong><code>EventUtil::IPPROTO_IPV6</code></strong>
     </dt>

     <dd>

      <p class="para">
       See the
       <em>socket(7)</em>
       manual page. (Added in event-1.6.0.)
      </p>
     </dd>

    
    
     <dt id="eventutil.constants.libevent-version-number">
      <strong><code>EventUtil::LIBEVENT_VERSION_NUMBER</code></strong>
     </dt>

     <dd>

      <p class="para">
       Libevent&#039; version number at the time when Event extension had been
       compiled with the library.
      </p>
     </dd>

    
   </dl>

  </div>

 </div>

 




































<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="eventutil.construct.html">EventUtil::__construct</a> — The abstract constructor</li><li><a href="eventutil.getlastsocketerrno.html">EventUtil::getLastSocketErrno</a> — Returns the most recent socket error number</li><li><a href="eventutil.getlastsocketerror.html">EventUtil::getLastSocketError</a> — Returns the most recent socket error</li><li><a href="eventutil.getsocketfd.html">EventUtil::getSocketFd</a> — Returns numeric file descriptor of a socket, or stream</li><li><a href="eventutil.getsocketname.html">EventUtil::getSocketName</a> — Retreives the current address to which the
  socket is bound.</li><li><a href="eventutil.setsocketoption.html">EventUtil::setSocketOption</a> — Sets socket options</li><li><a href="eventutil.sslrandpoll.html">EventUtil::sslRandPoll</a> — Generates entropy by means of OpenSSL's RAND_poll()</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="eventsslcontext.construct.html">EventSslContext::__construct</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="eventutil.construct.html">EventUtil::__construct</a></div>
 <div class="up"><a href="book.event.html">Event</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
